"""
钱吧申请模块
"""
import unittest
import requests
import time
from cookie import login

header = {'cookie': login.Logins()}
nowtime = time.strftime("%Y%m%d%H%M%S")
nowcustName = '孙芸筱'
nowidNo = '620423198812141166'


# 钱吧申请效验接口
class Rxd_QB_verify_Case(unittest.TestCase):

    def setUp(self):
        self.base_url = 'http://plsadmpre.cnsuning.com/plsadm/http/callBackQuotaAppl.do'

    def tearDown(self):
        print(self.result)

    def test_qb_sqxy(self):
        paydata = {'custName': nowcustName, 'idNo': nowidNo, 'serialNo': nowtime, 'transNo': nowtime,
                   'timestamp': nowtime, "addressDetail": '苏宁大道3号', "appCode": '70058302',
                   'app_id': 'yfbm70067441e2017120801', 'bizCode': '02', 'companyName': '苏宁有限公司',
                   'consumeDesc': '消费说明', 'contactAddress': '苏宁大道1号', 'contactPostCode': '210001',
                   'cooperativeAgency': '合作机构名称', 'custMobile': '18551631867', 'guaranteeType': '02', 'houseType': '1',
                   'idType': '01', 'industryType': 'T', 'intfNo': 'A0001', 'marryType': '2', 'matesCompany': '苏宁体育',
                   'matesIdNo': '320830198809180812', 'matesIdType': '01', 'matesName': '筱筱',
                   'matesPhone': '15600000000', 'maxDegree': '01', 'maxEducation': '01', 'occupation': '0',
                   'partnerNo': '15', 'payWay': 'R9929', 'plDescribe': '押品说明', 'pledgeType': '02', 'postCode': '210003',
                   'productNo': 'RXD', 'projectCode': '110', 'quotaRate': '0.000167', 'quotaStyle': '02',
                   'quotaTerm': '2', 'quotaType': '04', 'quotaUse': 'COS', 'quotaUseDesc': '买买买',
                   'server_address': 'https://fopenapipre.cnsuning.com:8443/gateway.htm',
                   'service': 'suning.fosps.pls.ExecuteRemotePlsadmPlatformServer.quotaApplyCheck', 'sign': '后台代码实现',
                   'sign_type': 'RSA2', 'signkey_index': '0001', 'termType': '02',
                   'uploadList[0].authDate': '20180224:084654', 'uploadList[0].uploadFileType': '15',
                   'uploadList[0].uploadNo': 'FOS2017111500002140', 'uploadList[0].uploadResult': '1', 'version': '1.0',
                   'workAddress': '苏宁大道2号', 'workDuties': '1', 'workDutiesName': '1', 'workPostCode': '210001'}
        r = requests.post(url=self.base_url, data=paydata, headers=header)
        self.result = r.json()
        if len(str(self.result)) > 50:
            result = eval(self.result['result'])
            self.assertEqual(result["status"], '01')
        else:
            self.assertEqual(self.result["result"], '成功')


if __name__ == '__main__':
    unittest.main()
